package kuang.juc.assist3;

import java.util.concurrent.CountDownLatch;

//线程减法计数器
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        //初始化计数
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 1; i <= 6; i++) {
            int finalI = i;
            new Thread(() -> {
                System.out.println(finalI + "Go");
                countDownLatch.countDown();
            }, String.valueOf(i)).start();
        }
        //计数器等待归零后才继续执行
        countDownLatch.await();
        System.out.println("锁门");
    }
}
